<?php if(!defined('BASEPATH'))exit('No direct script access allowed');
class tintuc extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->library('addin');
	}
	public function index($sotrang=1)
	{
        $this->load->model('sanpham_model');
		$data1['noibat'] = $this->sanpham_model->getNoiBat();
		$data1['counter'] = $this->addin->getcounter();
		$data1['online'] = $this->addin->getonline();
		$data1['thongke'] = $this->addin->thongKe();
		$data1['menu1'] = $this->addin->getMenuMain();
		$data1['menu2'] = $this->addin->getMenu3Cap();
		$this->load->model('tin_model');
		$data2['result'] = $this->tin_model->getNews();
		$this->load->view('required/header-trangcon',$data1);
		$this->load->view('tintuc/index',$data2);
		$this->load->view('required/footer',TRUE);
		//$this->output->enable_profiler(TRUE);
		//$menuloaitin : string (Menu loai tin chinh sua view = code)
		//result [] ten, tenUrl, hinh, tomtat //Url cho tin la: base_url('tintuc/chitiettin/'.$item->tenUrl.'.html')
		//counter : int : So nguoi da truy cap
		//online : int : So nguoi dang online
		//$menu1 : string (Chỉnh sửa lại chuỗi xuất ra)
		//$menu2 : string (Chỉnh sửa lại chuỗi xuất ra)
	}
	public function loaitin($tenLT)
	{
		if($tenLT==NULL)
		echo redirect(base_url('tintuc.html'));
		$this->load->model('tin_model');
        $this->load->model('sanpham_model');
		$data1['noibat'] = $this->sanpham_model->getNoiBat();
		$data2['result'] = $this->tin_model->getNewsFromTenLT($tenLT);
		if(count($data2['result'])==0) echo redirect(base_url('tintuc.html'));
		$data1['counter'] = $this->addin->getcounter();
		$data1['online'] = $this->addin->getonline();
		$data1['menu1'] = $this->addin->getMenuMain();
		$data1['menu2'] = $this->addin->getMenu3Cap();
		$data1['thongke'] = $this->addin->thongKe();
		$this->load->view('required/header-trangcon',$data1);
		$this->load->view('tintuc/loaitin',$data2);
		$this->load->view('required/footer',TRUE);
		//$menuloaitin : string (Menu loai tin chinh sua view = code)
		//result [] ten, tenUrl, hinh, tomtat
		//counter : int : So nguoi da truy cap
		//online : int : So nguoi dang online
		//$menu1 : string (Chỉnh sửa lại chuỗi xuất ra)
		//$menu2 : string (Chỉnh sửa lại chuỗi xuất ra)
	}
	public function chitiettin($tenUrl)
	{
        $this->load->model('sanpham_model');
		$data1['noibat'] = $this->sanpham_model->getNoiBat();
		$this->load->model('tin_model');
		$data1['counter'] = $this->addin->getcounter();
		$data1['online'] = $this->addin->getonline();
		$data1['thongke'] = $this->addin->thongKe();
		$data1['menu1'] = $this->addin->getMenuMain();
		$data1['menu2'] = $this->addin->getMenu3Cap();
		$this->load->view('required/header-trangcon',$data1);
		$data2['result'] = $this->tin_model->getNewsFromTenUrl($tenUrl);
		$this->load->view('tintuc/chitiettin',$data2);
		$this->load->view('required/footer',TRUE);
		//$menuloaitin : string (Menu loai tin chinh sua view = code)
		//result [] ten, hinh, tomtat, noidung
		//counter : int : So nguoi da truy cap
		//online : int : So nguoi dang online
		//$menu1 : string (Chỉnh sửa lại chuỗi xuất ra)
		//$menu2 : string (Chỉnh sửa lại chuỗi xuất ra)
	}
}